package com.example.day2arouter;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.example.day2arouter.entity.UserInfo;
import com.google.gson.Gson;

import static com.example.day2arouter.view.Path.DATA;

@Route(path = DATA)
public class DataActivity extends AppCompatActivity {

    @Autowired(name="name")
    String Name;
    @Autowired
    int age;

    @Autowired
    UserInfo info;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textView = new TextView(this);
        textView.setText("金库");

        //注入参数
        ARouter.getInstance().inject(this);
        if(Name!=null){
            Toast.makeText(this, ""+Name+"  "+age, Toast.LENGTH_SHORT).show();
        }
        if(info!=null){
            Gson gson = new Gson();
            Toast.makeText(this, ""+gson.toJson(info), Toast.LENGTH_SHORT).show();
        }
        setContentView(textView);
    }
}
